package com.ssy.lingxi.transaction.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.transaction.api.dto.request.*;
import com.ssy.lingxi.transaction.api.dto.response.ConfirmQuoteListResponse;
import com.ssy.lingxi.transaction.api.dto.response.NotarizeEnquiryQuotedPriceDetailsResponse;
import com.ssy.lingxi.transaction.api.dto.response.ProductQuotationDetailsResponse;
import com.ssy.lingxi.transaction.service.IConfirmQuoteService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @menu 交易中心-确认询价报价-APP
 * @author wrc
 * @date 2020/8/19
 */
@RestController
@RequestMapping("/transaction/mobile")
public class MobileConfirmQuoteController extends BaseController {

    @Resource
    IConfirmQuoteService notarizeEnquiryQuotedPriceService;

    /**
     * 确认询价报价-报价单列表查询
     */
    @GetMapping("/notarize/enquiry/product/quotation/list")
    public Wrapper<PageData<ConfirmQuoteListResponse>> notarizeEnquiryProductQuotationList(ProductQuotationListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
//        String shopId = httpServletRequest.getHeader("shopId");
//        if(StringUtils.isNotEmpty(shopId)){
//            request.setShopId(Long.valueOf(shopId));
//        }
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryProductQuotationList(request,sysUser);
    }

    /**
     * 确认询价报价-报价单详情
     */
    @GetMapping("/notarize/enquiry/product/quotation/details")
    public Wrapper<ProductQuotationDetailsResponse> productQuotationDetails(ProductQuotationDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.productQuotationDetails(request,sysUser);
    }

    /**
     * 询价报价-待提交报价单列表查询
     */
    @GetMapping("/notarize/enquiry/quoted/price/list")
    public Wrapper<PageData<ConfirmQuoteListResponse>> notarizeEnquiryQuotedPriceList(ProductQuotationListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        String shopId = httpServletRequest.getHeader("shopId");
        if(StringUtils.isNotEmpty(shopId)){
            request.setShopId(Long.valueOf(shopId));
        }
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceList(request,sysUser);
    }

    /**
     * 确认询价报价-待提交报价单详情
     */
    @ApiOperation(value = "确认询价报价-询价单详情")
    public Wrapper<NotarizeEnquiryQuotedPriceDetailsResponse> notarizeEnquiryQuotedPriceDetails(NotarizeEnquiryQuotedPriceDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceDetails(request,sysUser);
    }

    /**
     * 确认询价报价-提交审核
     */
    @PostMapping("/notarize/enquiry/quoted/price/submit")
    public Wrapper notarizeEnquiryQuotedPriceSubmit(@RequestBody NotarizeEnquiryQuotedPriceSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceSubmit(request,sysUser);
    }

    /**
     * 确认询价报价-批量提交审核
     */
    @PostMapping("/notarize/enquiry/quoted/price/submit/all")
    public Wrapper notarizeEnquiryQuotedPriceSubmitAll(@RequestBody NotarizeEnquiryQuotedPriceSubmitAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceSubmitAll(request,sysUser);
    }

    /**
     * 确认询价报价-待审核报价单查询
     */
    @GetMapping("/notarize/enquiry/quoted/price/audit/list")
    public Wrapper<PageData<ConfirmQuoteListResponse>> notarizeEnquiryQuotedPriceAuditList(ProductQuotationListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        String shopId = httpServletRequest.getHeader("shopId");
        if(StringUtils.isNotEmpty(shopId)){
            request.setShopId(Long.valueOf(shopId));
        }
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAuditList(request,sysUser);
    }

    /**
     * 确认询价报价-提交审核（一级）
     */
    @PostMapping("/notarize/enquiry/quoted/price/audit")
    public Wrapper notarizeEnquiryQuotedPriceAudit(@RequestBody NotarizeEnquiryQuotedPriceSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAudit(request,sysUser);
    }

    /**
     * 确认询价报价-批量提交审核（一级）
     */
    @PostMapping("/notarize/enquiry/quoted/price/audit/all")
    public Wrapper notarizeEnquiryQuotedPriceAuditAll(@RequestBody NotarizeEnquiryQuotedPriceSubmitAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAuditAll(request,sysUser);
    }

    /**
     * 确认询价报价-待审核报价单列表(二级)
     */
    @GetMapping("/notarize/enquiry/quoted/price/audit/list/two")
    public Wrapper<PageData<ConfirmQuoteListResponse>> notarizeEnquiryQuotedPriceAuditListTwo(ProductQuotationListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        String shopId = httpServletRequest.getHeader("shopId");
        if(StringUtils.isNotEmpty(shopId)){
            request.setShopId(Long.valueOf(shopId));
        }
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAuditListTwo(request,sysUser);
    }

    /**
     * 确认询价报价-提交审核(二级)
     */
    @PostMapping("/notarize/enquiry/quoted/price/audit/two")
    public Wrapper notarizeEnquiryQuotedPriceAuditTwo(@RequestBody NotarizeEnquiryQuotedPriceSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAuditTwo(request,sysUser);
    }

    /**
     * 确认询价报价-批量提交审核(二级)
     */
    @PostMapping("/notarize/enquiry/quoted/price/audit/all/two")
    public Wrapper notarizeEnquiryQuotedPriceAuditAllTwo(@RequestBody NotarizeEnquiryQuotedPriceSubmitAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAuditAllTwo(request,sysUser);
    }

    /**
     * 确认询价报价-待审核报价单列表
     */
    @GetMapping("/notarize/enquiry/quoted/price/affirm/list/")
    public Wrapper<PageData<ConfirmQuoteListResponse>> notarizeEnquiryQuotedPriceAffirmList(ProductQuotationListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        String shopId = httpServletRequest.getHeader("shopId");
        if(StringUtils.isNotEmpty(shopId)){
            request.setShopId(Long.valueOf(shopId));
        }
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAffirmList(request,sysUser);
    }

    /**
     * 确认询价报价-提交审核
     */
    @PostMapping("/notarize/enquiry/quoted/price/affirm")
    public Wrapper notarizeEnquiryQuotedPriceAffirm(@RequestBody NotarizeEnquiryQuotedPriceSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAffirm(request,sysUser);
    }

    /**
     * 确认询价报价-批量提交审核
     */
    @PostMapping("/notarize/enquiry/quoted/price/affirm/all")
    public Wrapper notarizeEnquiryQuotedPriceAffirmAll(@RequestBody NotarizeEnquiryQuotedPriceSubmitAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return notarizeEnquiryQuotedPriceService.notarizeEnquiryQuotedPriceAffirmAll(request,sysUser);
    }
}
